/*
 * Copyright (c) 2018-2999 九五云信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 */

package com.yami.shop.api.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.model.ShopRenovation;
import com.yami.shop.common.annotation.SysLog;
import com.yami.shop.common.config.Constant;
import com.yami.shop.common.exception.YamiShopBindException;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.security.api.util.SecurityUtils;
import com.yami.shop.service.ShopRenovationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Objects;


/**
 * 店铺装修信息
 *
 * @author lhd
 * @date 2021-01-05 11:03:38
 */
@RestController
@AllArgsConstructor
@Api(tags = "店铺装修信息")
@RequestMapping("/shopRenovation" )
public class ShopRenovationController {

    private final ShopRenovationService shopRenovationService;


    /**
     * 通过id查询店铺装修信息
     * @param shopId id
     * @return 单个数据
     */
    @GetMapping("/info" )
    @ApiOperation(value = "店铺装修信息", notes = "根据店铺id,模板id,店铺装修信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "shopId", value = "店铺id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "renovationId", value = "模板id", required = true, dataType = "Integer")
    })
    public ResponseEntity<ShopRenovation> getById(Long shopId,Long renovationId) {
        ShopRenovation shopRenovation = shopRenovationService.getOne(new LambdaQueryWrapper<ShopRenovation>()
                .eq(ShopRenovation::getShopId,shopId).eq(ShopRenovation::getRenovationId,renovationId));
        return ResponseEntity.ok(shopRenovation);
    }

    /**
     * 返回主页id
     * @return 单个数据
     */
    @GetMapping("/getHomePage" )
    @ApiOperation(value = "店铺装修信息", notes = "根据店铺id,模板id,店铺装修信息")
    public ResponseEntity<ShopRenovation> getHomePage() {
        ShopRenovation shopRenovation = shopRenovationService.getOne(new LambdaQueryWrapper<ShopRenovation>()
                .eq(ShopRenovation::getShopId, Constant.PLATFORM_SHOP_ID).eq(ShopRenovation::getHomeStatus,1));
        return ResponseEntity.ok(shopRenovation);
    }

}
